Skip to content

fix(iam-admin): remove redundant IAM project service to prevent state conflict#13016

Merged
blakeli0 merged 1 commit intomainfrom
fix/iam-admin-terraform-race
May 6, 2026
Merged

fix(iam-admin): remove redundant IAM project service to prevent state conflict#13016
blakeli0 merged 1 commit intomainfrom
fix/iam-admin-terraform-race

Conversation

@blakeli0
Copy link
Copy Markdown
Contributor

@blakeli0 blakeli0 commented May 5, 2026

Summary

This PR addresses a Terraform state conflict in the java-iam-admin module's integration setup.

Previously, both the root .cloud module and the java-iam-admin submodule were managing the iam.googleapis.com service activation on the same project. In Terraform, managing the exact same physical cloud resource in multiple places within the state tree causes resource conflicts/fighting. This conflict was the root cause of the transient "Provider produced inconsistent result after apply" failures during terraform apply.

Since the root .cloud module already manages iam.googleapis.com and introduces a 1-minute warmup sleep before applying any submodules, java-iam-admin does not need to manage this API.

This fix removes the redundant google_project_service.iam activation and its associated sleeps from the submodule, simplifying it to the minimum required resources to successfully and stably create the service account.

Verification

  • Bypasses the state conflict entirely, resolving the integration test flakiness.
  • Removes the submodule delay entirely, making the java-iam-admin integration setup faster.

@blakeli0 blakeli0 requested a review from a team as a code owner May 5, 2026 22:43
@blakeli0 blakeli0 changed the title fix(iam-admin): add 90s warmup delay to prevent service account creation race condition tests(iam-admin): add 90s warmup delay to prevent service account creation race condition May 5, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 90-second delay using a time_sleep resource after enabling the IAM API to ensure it is fully operational before the service account is created. Feedback suggests adding a conditional count to the time_sleep resource so the delay only occurs when the API is actually being enabled by the Terraform configuration, preventing unnecessary wait times when the API is already active.

Comment thread java-iam-admin/.cloud/main.tf Outdated
Comment on lines +14 to +17
resource "time_sleep" "for_90s_allowIamToFullyEnable" {
depends_on = [google_project_service.iam]
create_duration = "90s"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The time_sleep resource should only be active when the IAM API is being enabled by this Terraform configuration. As currently implemented, it will introduce a 90-second delay during the initial terraform apply even if should_enable_apis_on_apply is set to false. Adding a count to match the google_project_service.iam resource ensures the delay only occurs when the API is actually being managed and enabled here.

resource "time_sleep" "for_90s_allowIamToFullyEnable" {
  count           = var.inputs.should_enable_apis_on_apply ? 1 : 0
  depends_on      = [google_project_service.iam]
  create_duration = "90s"
}

@blakeli0 blakeli0 force-pushed the fix/iam-admin-terraform-race branch from 9d1b9de to 96390cc Compare May 5, 2026 22:48
@blakeli0 blakeli0 requested a review from jinseopkim0 May 5, 2026 22:49
@blakeli0 blakeli0 force-pushed the fix/iam-admin-terraform-race branch from 96390cc to 424d2d8 Compare May 6, 2026 01:09
@blakeli0 blakeli0 changed the title tests(iam-admin): add 90s warmup delay to prevent service account creation race condition fix(iam-admin): remove redundant IAM project service to prevent state conflict May 6, 2026
@blakeli0 blakeli0 merged commit 95cfd5e into main May 6, 2026
123 of 124 checks passed
@blakeli0 blakeli0 deleted the fix/iam-admin-terraform-race branch May 6, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants